package com.cadre.web.controller.officer;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.cadre.common.utils.R;
import com.cadre.common.utils.oldutil.ValidatorUtils;
import com.cadre.system.domain.officer.BTagtabEntity;
import com.cadre.system.service.BTagtabService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;

@RequestMapping({"/smart"})
@RestController
/* loaded from: BTagtabController.class */
public class BTagtabController {
    @Autowired
    private BTagtabService bTagtabService;

    @RequestMapping({"/list"})
//    @RequiresPermissions({"sys:btagtab:list"})
    public R list(@RequestParam Map<String, Object> params) {
        return R.ok().put("page", (Object) this.bTagtabService.queryPage(params));
    }

    @RequestMapping({"/select/{id}"})
    public R info(@PathVariable("id") Long id) {
        List<BTagtabEntity> list;
        new ArrayList();
        if (id.longValue() == 53) {
            list = this.bTagtabService.selectDIC_ZB131();
        } else {
            //（已调整完毕） todo: 需要调整加上排序
            list = this.bTagtabService.getBaseMapper().selectList(new LambdaQueryWrapper<BTagtabEntity>()
                    .eq(BTagtabEntity::getParentid, id).orderByAsc(BTagtabEntity::getSortid));//.orderByAsc(new BTagtabEntity(),BTagtabEntity::getSortid));
        }
        return R.ok().put("bTagtab", (Object) list);
    }

    @RequestMapping({"/save"})
//    @RequiresPermissions({"sys:btagtab:save"})
    public R save(@RequestBody BTagtabEntity bTagtab) {
        this.bTagtabService.getBaseMapper().insert(bTagtab);
        return R.ok();
    }

    @RequestMapping({"/update"})
//    @RequiresPermissions({"sys:btagtab:update"})
    public R update(@RequestBody BTagtabEntity bTagtab) {
        ValidatorUtils.validateEntity(bTagtab, new Class[0]);
        this.bTagtabService.getBaseMapper().updateById(bTagtab);
        return R.ok();
    }

    @RequestMapping({"/delete"})
//    @RequiresPermissions({"sys:btagtab:delete"})
    public R delete(@RequestBody Long[] ids) {
        this.bTagtabService.getBaseMapper().deleteBatchIds(Arrays.asList(ids));
        return R.ok();
    }
}
